package com.link.play.fit.ai.ui.guide

import android.os.Bundle
import android.text.Spannable
import android.text.SpannableString
import android.text.style.UnderlineSpan
import android.view.View
import com.link.play.fit.ai.R
import com.link.play.fit.ai.databinding.FgWelcomePrivacyBinding
import com.link.play.fit.ai.ui.guide.ac.WelcomeAc


class WelcomePrivacyFg :
    BasePageFragment<FgWelcomePrivacyBinding>(FgWelcomePrivacyBinding::inflate) {
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)


        val terms = getString(R.string.terms_conditions)
        val termsSp = SpannableString(terms)

        termsSp.setSpan(
            UnderlineSpan(),  // 下划线样式
            0,                // 起始位置
            terms.length,      // 结束位置
            Spannable.SPAN_INCLUSIVE_EXCLUSIVE
        )

        binding.tvTerms.text = termsSp


        val privacy = resources.getString(R.string.privacy_policy)
        val privacySp = SpannableString(privacy)

        privacySp.setSpan(
            UnderlineSpan(),  // 下划线样式
            0,                // 起始位置
            privacy.length,      // 结束位置
            Spannable.SPAN_INCLUSIVE_EXCLUSIVE
        )

        binding.tvPrivacy.text = privacySp
        binding.ivCheck.buttonDrawable = null
        binding.ivCheck.setOnCheckedChangeListener { _, isChecked ->
            (requireActivity() as WelcomeAc).isAgree=isChecked
        }
    }
}
